package com.fizzkai.p2p.mgrsite.controller;

import com.fizzkai.p2p.core.domain.RealAuth;
import com.fizzkai.p2p.core.query.RealAuthQuery;
import com.fizzkai.p2p.core.service.IRealAuthService;
import com.fizzkai.p2p.core.util.AjaxResult;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
public class RealAuthController {

    @Autowired
    private IRealAuthService authService;

    @RequestMapping("/realAuth")
    public String realAuth(@ModelAttribute("qo") RealAuthQuery qo, Model model){
        PageInfo<RealAuth> pageInfo = authService.query(qo);
        model.addAttribute("pageInfo", pageInfo);
        return "realAuth/list";
    }

    @RequestMapping("/realAuth_audit")
    @ResponseBody
    public Object realAuth_audit(Integer state, String remark, Long id) {
        authService.audit(id, state, remark);
        return new AjaxResult(state == RealAuth.STATE_PASS ? "审核成功" : "拒审成功");
    }

}
